<template>
	<view class="brand-list-view">
		<view class="header">
			<my-search :bgcolor="'#e5e6eb'" :search_box_bgcolor="'#fff'" :color="'#939aa3'" @search="gotoSearch">
			</my-search>
		</view>
		<view class="idx-list-view">
			<uni-indexed-list :options="brand_list" @click="bindClick">
			</uni-indexed-list>
		</view>
	</view>
</template>

<script>
	export default {

		data() {
			return {
				brand_list: []
			};
		},

		onLoad() {
			this.load()
		},

		methods: {
			async load() {
				this.brand_list = await uni.$api.brand.getAllBrand() || []
				uni.showLoading({
					title: '加载中...',
				})
				setTimeout(() => {
					uni.hideLoading()
				}, 500)
			},
			// 跳转
			gotoSearch() {
				uni.navigateTo({
					url: '/pagesSub/pageFridge/brand_search/brand_search?list=' + JSON.stringify(this.brand_list)
				})
			},
			bindClick(e) {
				uni.navigateTo({
					url: '/pagesSub/pageFridge/select_model/select_model?bid=' + e.item.bid + '&name=' + e.item
						.name +
						'&img=' + e.item.imgSrc
				})
			}
		}
	}
</script>

<style lang="scss">
	.brand-list-view {
		.header {
			position: sticky;
			top: 0;
		}
	}
</style>